package model.inventory;
// Generated Oct 27, 2012 8:43:23 AM by Hibernate Tools 3.2.1.GA


import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * MstItemDiskon generated by hbm2java
 */
@Entity
@Table(name="mst_item_diskon",schema="inventory")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class ItemDiskon  implements java.io.Serializable {

    private ItemDiskonId id;
    private ItemHpp itemHpp;
    private String jenis;
    private Date beginDate;
    private Date endDate;
    private BigDecimal diskon = BigDecimal.ZERO;

    public ItemDiskon() {
        this.id = new ItemDiskonId();
        this.beginDate = new Date();
        this.endDate = new Date();
    }

    public ItemDiskon(String jenis) {
        this.id = new ItemDiskonId();
        this.jenis = jenis;
        this.beginDate = new Date();
        this.endDate = new Date();
    }
    
    @EmbeddedId
    @AttributeOverrides( {
        @AttributeOverride(name="itemId", column=@Column(name="item_id", nullable=false) ), 
        @AttributeOverride(name="startDate", column=@Column(name="start_date", nullable=false, length=13) ), 
        @AttributeOverride(name="supplierId", column=@Column(name="supplier_id", nullable=false) ), 
        @AttributeOverride(name="seq", column=@Column(name="seq", nullable=false) ) } )
    public ItemDiskonId getId() {
        return this.id;
    }
    
    public void setId(ItemDiskonId id) {
        this.id = id;
    }
    
    @ManyToOne
    @JoinColumns( { 
        @JoinColumn(name="item_id", referencedColumnName="item_id", nullable=false, insertable=false, updatable=false), 
        @JoinColumn(name="start_date", referencedColumnName="start_date", nullable=false, insertable=false, updatable=false), 
        @JoinColumn(name="supplier_id", referencedColumnName="supplier_id", nullable=false, insertable=false, updatable=false) } )
    public ItemHpp getItemHpp() {
        return this.itemHpp;
    }
    
    public void setItemHpp(ItemHpp itemHpp) {
        this.itemHpp = itemHpp;
    }
    
    @Column(name="jenis", length=1)
    public String getJenis() {
        return this.jenis;
    }
    
    public void setJenis(String jenis) {
        this.jenis = jenis;
    }
    
    @Column(name="diskon", precision=12, scale=3)
    public BigDecimal getDiskon() {
        return this.diskon;
    }
    
    public void setDiskon(BigDecimal diskon) {
        this.diskon = diskon;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="begin_date", length=13)
    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }
    
    @Temporal(TemporalType.DATE)
    @Column(name="end_date", length=13)
    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public static ItemDiskon clone(ItemDiskon original) {
        ItemDiskon copy = new ItemDiskon();
        if (original != null) {
            copy.setId(new ItemDiskonId(
                        original.getId().getItemId(), original.getId().getStartDate(), 
                        original.getId().getSupplierId(), original.getId().getSeq()));
            copy.setDiskon(original.getDiskon());
            copy.setJenis(original.getJenis());
            copy.setBeginDate(original.getBeginDate());
            copy.setEndDate(original.getEndDate());
        }
        return copy;
    }
}


